package com.cisetech.web.bobocai.houtai;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cisetech.service.YouQingService;
import com.cisetech.vo.Page;
import com.cisetech.vo.bobocai.LCustomerMessage;
import com.cisetech.vo.bobocai.YouQingVo;

/**
 * 友情链接控制器
 * @author Administrator
 *
 */
@Controller
@RequestMapping(value="/ht/youqing")
public class YouQingController {
	
	@Autowired
	YouQingService youQingService;
	
	@RequestMapping(value="/init")
	public String initYouQing(HttpServletRequest request , HttpServletResponse response){
		
		return "/houtai/youqing";
	}
	@RequestMapping(value="/addYouQingLianJie")
	public String addYouQingLianJie(HttpServletRequest request , HttpServletResponse response){
		
		return "/houtai/addyouqinglianjie";
	}
	@ResponseBody
	@RequestMapping(value="/addYouQingLianJie",method=RequestMethod.POST)
	public String addYouQing(HttpServletRequest request , HttpServletResponse response,YouQingVo youQingVo){
		try {
			if (youQingVo.getName()==null || "".equals(youQingVo.getName())){
				return "3";//公司名称不能为空
			}
			if (youQingVo.getEname()==null || "".equals(youQingVo.getEname())){
				return "4";//英文公司名称不能为空
			}
			if (youQingVo.getUrl()==null || "".equals(youQingVo.getUrl())){
				return "5";//url不能为空
			}
			int i = youQingService.addYouQing(youQingVo);
			return i + "";
		} catch (Exception e) {
			return "2";
		}
	}
	@ResponseBody
	@RequestMapping(value="getList",method=RequestMethod.POST)
	public Page<YouQingVo> getList(YouQingVo youQingVo,HttpServletResponse response,HttpServletRequest request){
		Page<YouQingVo> page = youQingService.getList(youQingVo);
		return page;
	}
	@ResponseBody
	@RequestMapping(value="delete",method=RequestMethod.POST)
	public String delete(YouQingVo youQingVo,HttpServletResponse response,HttpServletRequest request){
		try {
			youQingService.delete(youQingVo.getIds());
			return "0";
		} catch (Exception e) {
			return "1";
		}
	}
	@ResponseBody
	@RequestMapping(value="updateType",method=RequestMethod.POST)
	public String updateType(YouQingVo youQingVo,HttpServletResponse response,HttpServletRequest request){
		try {
			youQingService.updateType(youQingVo);
			return "0";
		} catch (Exception e) {
			return "1";
		}
	}
}
